|
|
|
|
|
|
|
Fortunately, the answer is yes. Visual Basic provides a tool called the ActiveX Document Migration Wizard that can help you convert forms from an existing application to UserDocument objects for an ActiveX document. The key word here is "help." The wizard does not create a complete ActiveX document directly from your standard application. Instead, the wizard does the following: |
|
|
|
|
|
|
|
|
Copies the properties of the forms to new user documents. |
|
|
|
|
|
|
|
|
Copies menu items from the source forms to the new user documents. |
|
|
|
|
|
|
|
|
Copies all controls from the source forms, retaining their relative positions on the forms. All control properties are retained. Note that OLE container controls and embedded OLE objects are not copied. |
|
|
|
|
|
|
|
|
Copies the code from the form event procedures to the corresponding procedures in the user document, including all event procedures associated with the component controls. |
|
|
|
|
|
|
|
|
Comments out code statements that are not supported by ActiveX documents, such as Load, Unload, and End. |
|
|
|
|
|
|
|
|
Although the ActiveX Document Migration Wizard can do a lot of the work of converting a document for you, it cannot handle some processes. Therefore, you have to do some coding work before you can compile and distribute your document. |
|
|
|
|
|
|
|
|
First, you need to remove unsupported events, such as Load and Unload. Although the wizard comments out the Load and Unload statements, it does not do anything with the event procedures code. If you use these events to initialize the properties of a form or its controls, you may want to move some of the code from the Load event to the Initialize event of the UserDocument. Likewise, you may want to move some of the code from the Unload event to the Terminate event of the UserDocument. |
|
|
|
|
|
|
|
|
You also need to make sure that you do not reference any nonexistent objects. For example, if you migrate a form to a UserDocument, any references to the form by name (for example, Form1) are invalid. |
|
|
|
|
|
|
|
|
Running the ActiveX Document Migration Wizard |
|
|
|
|
|
|
|
|
To run the ActiveX Document Migration Wizard, you need to make sure that it is available in Visual Basic. You make the wizard available by selecting it from the Add-In Manager dialog box, which you can access by choosing Add-In Manager from the Add-Ins menu. After you add the wizard to the Visual Basic IDE, you can run it by choosing ActiveX Document Migration Wizard from the Add-Ins menu. |
|
|
|
|
|
|
|
|
The following steps describe the process of converting the forms of a project into ActiveX documents: |
|
|
|
|
|
|
|
|
1. Open the project whose forms you want to convert. The wizard works correctly only from within the project. |
|
|
|
|
|
|
|
|
2. Start the ActiveX Document Migration Wizard. You first see the introductory screen, which explains a little of what the wizard will and will not do for you. Click the Next button to proceed. |
|
|
|
|
|